package com.dragonlance.net;

import org.apache.mina.core.session.IoSession;

import com.dragonlance.DLClient;
import com.dragonlance.DLServer;

public class PackageInHandler {
	public void handle(PackageIn pkg,IoSession session){
		try{
			switch(pkg.code)
			{
				case DLInProtocolNumber.LOGIN:
					DLServer.getInstance().getClientMgr().loginClient(pkg,session);
					break;
				case DLInProtocolNumber.CHAT:
					String msg = pkg.readUtf();
					DLClient client = DLServer.getInstance().getClientMgr().getClient(session.getId());
					if(client!=null){
						DLServer.getInstance().getClientMgr().sendChatToAll(msg,client.getUser().getNickName(),1);
					}
					break;
			}
		}catch(Exception e){
			
		}
	}
}
